package com.gxa.eshop.portal.service.impl;

import com.gxa.eshop.core.pojo.Banner;
import com.gxa.eshop.portal.dao.BannerRepository;
import com.gxa.eshop.portal.service.BannerService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("bannerService")
public class BannerServiceImpl implements BannerService {

    @Resource
    BannerRepository bannerRepository;

    @Override
    public List<Banner> selectAllByPosition(String postion) {

        Banner banner = new Banner();
        banner.setPosition(postion);
        Example<Banner> of = Example.of(banner);
        Sort id = Sort.by(Sort.Direction.ASC, "id");

        return bannerRepository.findAll(of,id);
    }
}
